<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-admin-menu">
        <input type="hidden" id="id" name="id" value="{$data.menuid}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">上级权限</label>
            <div class="formControls col-xs-8 col-sm-4">
                <span class="select-box" style="width:150px;">
                    <select class="select" id="pid" name="pid" title="上级权限">
                        <option value="0" {eq name='data.pid' value="0" }selected{/eq}>--新增顶级权限--</option>
                        {foreach $menus as $value}
                        <option value="{$value.menuid}" {eq name='data.pid' value="$value.menuid" }selected{/eq}>
                            ----{$value.name}----</option>
                        {notempty name="value.child"}
                        {foreach $value.child as $val}
                        <option value="{$val.menuid}" {eq name='data.pid' value="$val.menuid" }selected{/eq}>
                            &nbsp;&nbsp;&nbsp;&nbsp;* {$val.name}---</option>
                        {/foreach}
                        {/notempty}
                        {/foreach}
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span> 菜单名称:</label>
            <div class="formControls col-xs-8 col-sm-4">
                <input type="text" class="input-text" value="{$data.name}" placeholder="请输入目录名称" id="name"
                    name="name" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span> url:</label>
            <div class="formControls col-xs-8 col-sm-4">
                <input type="text" class="input-text" value="{$data.url}" placeholder="请输入url,目录无需填写" id="url"
                    name="url" />
            </div>
            <span style="color:red;">* 小写字母</span>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">目录类型:</label>
            <div class="formControls col-xs-8 col-sm-2">
                <span class="select-box" style="width:150px;">
                    <select class="select" id="type" name="type" title="目录类型">
                        <option value="0" {eq name='data.type' value="0" }selected{/eq}>目录</option>
                        <option value="1" {eq name='data.type' value="1" }selected{/eq}>菜单</option>
                        <option value="2" {eq name='data.type' value="2" }selected{/eq}>按钮</option>
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">图标样式:</label>
            <div class="formControls col-xs-4 col-sm-2">
                <input type="text" class="input-text" value="{$data.icon}" placeholder="图片值" id="icon" name="icon" />
            </div>
            <div class="formControls col-xs-2 col-sm-2">
                (按钮无需图标)预览：<i class="Hui-iconfont">{$data.icon|raw}</i>
            </div>
            <span style="color:red;">* 图标示例 <a href="/static/plugins/Hui-iconfont/1.0.8/demo.html" target="_blank"
                    style="color:blue;" rel="noopener noreferrer"> demo</a></span>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" id="admin-powers-save" name="">确&nbsp;定</button>
                <button type="button" class="btn btn-default radius" onclick="layer_close();"
                    style="margin-left:20px;">取&nbsp;消</button>
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {
        $("#admin-powers-save").click(function () {
            var data = $("#form-admin-menu").serializeArray();
            $.ajax({
                type: 'POST',
                url: '{:url("save")}',
                data: data,
                dataType: 'json',
                success: function(res) {
                    // console.log(res);
                    if (res.code==0) {
                        layer.msg(res.msg,{icon:1},function(){
                            parent.location.reload(); // 父页面刷新
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 1000
                        });
                        return false;
                    }
                }
            })
        });
    })
</script>